package com.media.entrance.mapper;

import com.media.entrance.model.MatchAndResourceModel;
import com.media.entrance.model.MatchInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MatchMapper {

    // 根据坐席ID查询匹配结果
//    @Select(value = "select * from RealtimeMatching where agentId = #{agentId}")
    MatchInfo findByInitAgentId(@Param("agentId")String agentId);
    MatchInfo findByInitAgentIdWithLock(@Param("agentId")String agentId);
    MatchInfo findByAgentId(@Param("agentId")String agentId);
    MatchInfo findByAgentIdWithLock(@Param("agentId")String agentId);
    MatchInfo findByAgentStatus(@Param("agentStatus")String agentStatus);

    MatchInfo findIdleAgentStatusExceptAgentId(@Param("agentId")String agentId);
    MatchInfo findByDeviceId(@Param("deviceId")String deviceId);
    MatchInfo findByDeviceIdWithLock(@Param("deviceId")String deviceId);
    MatchInfo findByRoomId(@Param("roomId")String roomId);
    List<MatchInfo> findAllByAgentStatus(@Param("agentStatus")String agentStatus);

    // 签入 创建坐席记录
//    @Options(useGeneratedKeys = true, keyProperty = "agentId")
//    @Insert("insert into RealtimeMatching(agentId, agentStatus) VALUSE (#{agentId}, #{agentStatus})")
    int insertMatchInfo(MatchInfo matchInfo);

    // 签出 删除坐席记录
//    @Delete("DELETE FROM RealtimeMatching WHERE agentId = #{agentId}")
    int deleteByAgentId(@Param("agentId") String agentId);

    // 更新 坐席状态
//    @Update("UPDATE RealtimeMatching SET agentStatus = #{agentStatus} WHERE agentId = #{agentId}")
    int updateMatchInfo(MatchInfo matchInfo);
    int updateInitMatchInfo(MatchInfo matchInfo);
    int updateIdleMatchInfo(MatchInfo matchInfo);
    int updateRingMatchInfo(MatchInfo matchInfo);
    int updateBusyMatchInfo(MatchInfo matchInfo);

    int updateRestMatchInfo(MatchInfo matchInfo);
    int updatePauseMatchInfo(MatchInfo matchInfo);

    int insertMatchAndResourceModelToAgentRecorder(MatchAndResourceModel matchInfo);
    int insertMatchAndResourceModelToDeviceRecorder(MatchAndResourceModel matchInfo);
}
